How to delete a folder in python when [Error 32] is present

Posted by harish on Super User See other posts from Super User or by harish
Published on 2013-11-05T09:39:10Z Indexed on 2013/11/05 9:58 UTC
Read the original article Hit count: 195

I am using python 2.7. I want to delete a folder which may or may not be empty. The folder is handled by thread for file-monitoring. I am not able to kill thread but wanted to delete this folder any how. I tried with

os.rmdir(Location)
shutil.rmtree(Location) 
os.unlink(Location)

But, it didn't work. It is showing error as [Error 32] The process cannot access the file because it is being used by another process: 'c:\\users\\cipher~1\\appdata\\local\\temp\\fis\\a0c433973524de528420bbd56f8ede609e6ea700' I want to delete folder a0c433973524de528420bbd56f8ede609e6ea700 or delete whole path will also suffice.

© Super User or respective owner

Related posts about python

Related posts about multi-threaded